package com.lzy.controller;

import com.lzy.base.BaseInfoProperties;
import com.lzy.grace.result.GraceJSONResult;
import com.lzy.pojo.FriendCircleLiked;
import com.lzy.pojo.bo.CommentBO;
import com.lzy.pojo.bo.FriendCircleBO;
import com.lzy.pojo.vo.CommentVO;
import com.lzy.pojo.vo.FriendCircleVO;
import com.lzy.service.CommentService;
import com.lzy.service.FriendCircleService;
import com.lzy.utils.PagedGridResult;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;


@RestController
@RequestMapping("comment")
public class CommentController extends BaseInfoProperties {

    @Autowired
    private CommentService commentService;

    @PostMapping("create")
    public GraceJSONResult create(@RequestBody CommentBO commentBO,
                                   HttpServletRequest request){
        CommentVO commentVO = commentService.createComment(commentBO);
        return GraceJSONResult.ok(commentVO);
    }


    @PostMapping("query")
    public GraceJSONResult query(@RequestBody String friendCircleId,
                                  HttpServletRequest request){
        return GraceJSONResult.ok(commentService.queryAll(friendCircleId));
    }

    @PostMapping("delete")
    public GraceJSONResult delete(String commentUserId,
                                  String commentId,
                                  String friendCircleId){

        if(StringUtils.isBlank(commentUserId) ||
                StringUtils.isBlank(commentId) ||
                StringUtils.isBlank(friendCircleId))
        {
            return GraceJSONResult.error();
        }
        commentService.deleteComment(commentUserId,commentId,friendCircleId);
        return GraceJSONResult.ok();
    }

}